import React from 'react'
export default class StateDemo extends React.Component{
  constructor(props) {
    super(props)
    this.state = {
      x:0
    }
  }
  render() {
    return (
      <div>{this.state.x}
        <button onClick={() => {
          this.setState({ x: this.state.x + 1 })
          this.setState((state) => {
            return {x:state.x+1}
          }, () => {
            console.log('render finish')
          })
        }}>
          click
        </button>
      </div>
    )
  }
}